/**
*  
* @Function 区域部门同步定时任务 
* @ProjectName credit-data-platform 
* @PackageName com.py.credit.controller    
* @FileName AreaDeptController.java    
* @Date 2018年6月5日下午2:10:01
* @Author Min DongXv
* @Copyright (c) 2018, 金电联行 All Rights Reserved.   
*   
*/  
package com.py.credit.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.py.credit.common.logs.ExceptionLogger;
import com.py.credit.common.rest.RestServiceResult;
import com.py.credit.service.AreaDeptService;
import com.py.framework.core.annotation.IgnoreAuthority;

/**
 * 
 * @Function 区域部门同步定时任务
 * @ClassName AreaDeptController
 * @Date 2018年6月5日 下午2:10:01
 * @Author Min DongXv
 * 
 */
@RestController
@RequestMapping(value = "/syncAreaDept")
public class AreaDeptController {

	@Autowired
	private AreaDeptService areaDeptService;

	/**
	 * 
	 * @api {get} /syncAreaDept/syncArea.do 同步区域信息
	 * @apiName syncArea
	 * @apiVersion 0.0.1
	 * @apiGroup 区域部门同步定时任务
	 * @apiSuccess {String} code 状态码:1 成功 -1 失败
	 * @apiSuccess {String} msg 错误信息
	 * @apiSuccess {int} count 结果集数据量
	 * @apiSuccess {String} data 结果集
	 */
	@IgnoreAuthority
	@RequestMapping("/syncArea.do")
	public RestServiceResult<Object> syncArea() {
		RestServiceResult<Object> result = new RestServiceResult<Object>();
		try {
			areaDeptService.syncArea();
			return result;
		} catch (Exception e) {
			result.setCode(RestServiceResult.CODE_UNKNOW);
			result.setMsg("同步区域数据异常！");
			ExceptionLogger.error("AreaDeptController#syncArea", "同步区域数据异常！ERROR:" + e.getMessage(), e);
			return result;
		}
	}

	/**
	 * 
	 * @api {get} /syncAreaDept/syncDept.do 同步部门数据
	 * @apiName syncDept
	 * @apiVersion 0.0.1
	 * @apiGroup 区域部门同步定时任务
	 * @apiSuccess {String} code 状态码:1 成功 -1 失败
	 * @apiSuccess {String} msg 错误信息
	 * @apiSuccess {int} count 结果集数据量
	 * @apiSuccess {String} data 结果集
	 */
	@IgnoreAuthority
	@RequestMapping("/syncDept.do")
	public RestServiceResult<Object> syncDept() {
		RestServiceResult<Object> result = new RestServiceResult<Object>();
		try {
			areaDeptService.syncDept();
			return result;
		} catch (Exception e) {
			result.setCode(RestServiceResult.CODE_UNKNOW);
			result.setMsg("同步部门数据异常！");
			ExceptionLogger.error("AreaDeptController#syncDept", "同步部门数据异常！ERROR:" + e.getMessage(), e);
			return result;
		}
	}
	@IgnoreAuthority
	@RequestMapping("/syncUser.do")
	public RestServiceResult<Object> syncUser() {
		RestServiceResult<Object> result = new RestServiceResult<Object>();
		try {
			areaDeptService.syncUser();
			return result;
		} catch (Exception e) {
			result.setCode(RestServiceResult.CODE_UNKNOW);
			result.setMsg("同步用户数据异常！");
			ExceptionLogger.error("AreaDeptController#syncUser", "同步用户数据异常！ERROR:" + e.getMessage(), e);
			return result;
		}
	}
}
